home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #9 / Amiga Plus CD - 2004 - No. 09.iso / amigaplus / tools / amigaos4_only / smbfs / source / assert.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-08-03  |  4.4 KB  |  122 lines

  1. /*
  2.  * $Id: assert.h,v 1.34 2004/05/16 09:51:36 obarthel Exp $
  3.  *
  4.  * :ts=8
  5.  *
  6.  * SMB file system wrapper for AmigaOS, using the AmiTCP V3 API
  7.  *
  8.  * Copyright (C) 2000-2004 by Olaf `Olsen' Barthel <olsen@sourcery.han.de>
  9.  *
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2 of the License, or
  13.  * (at your option) any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  */
  24.  
  25. #ifndef _ASSERT_H
  26. #define _ASSERT_H 1
  27.  
  28. /****************************************************************************/
  29.  
  30. /* IMPORTANT: If DEBUG is redefined, it must happen only here. This
  31.  *            will cause all modules to depend upon it to be rebuilt
  32.  *            by the smakefile (that is, provided the smakefile has
  33.  *            all the necessary dependency lines in place).
  34.  */
  35.  
  36. /*#define DEBUG*/
  37.  
  38. /****************************************************************************/
  39.  
  40. #ifdef ASSERT
  41. #undef ASSERT
  42. #endif   /* ASSERT */
  43.  
  44. #define PUSH_ASSERTS()  PUSHDEBUGLEVEL(0)
  45. #define PUSH_REPORTS()  PUSHDEBUGLEVEL(1)
  46. #define PUSH_CALLS() PUSHDEBUGLEVEL(2)
  47. #define PUSH_ALL()   PUSHDEBUGLEVEL(2)
  48. #define POP()     POPDEBUGLEVEL()
  49.  
  50. #if defined(DEBUG) /*&& defined(__SASC)*/
  51.  void _ASSERT(int x,const char *xs,const char *file,int line,const char *function);
  52.  void _SHOWVALUE(unsigned long value,int size,const char *name,const char *file,int line);
  53.  void _SHOWPOINTER(void *p,const char *name,const char *file,int line);
  54.  void _SHOWSTRING(const char *string,const char *name,const char *file,int line);
  55.  void _SHOWMSG(const char *msg,const char *file,int line);
  56.  void _ENTER(const char *file,int line,const char *function);
  57.  void _LEAVE(const char *file,int line,const char *function);
  58.  void _RETURN(const char *file,int line,const char *function,unsigned long result);
  59.  void _DPRINTF_HEADER(const char *file,int line);
  60.  void _DPRINTF(const char *format,...);
  61.  void _DLOG(const char *format,...);
  62.  int  _SETDEBUGLEVEL(int level);
  63.  void _PUSHDEBUGLEVEL(int level);
  64.  void _POPDEBUGLEVEL(void);
  65.  int  _GETDEBUGLEVEL(void);
  66.  void _SETPROGRAMNAME(char *name);
  67.  void _INDENT(void);
  68.  
  69.  #define ASSERT(x)      _ASSERT((int)(x),#x,__FILE__,__LINE__,__FUNC__)
  70.  #define ENTER()     _ENTER(__FILE__,__LINE__,__FUNC__)
  71.  #define LEAVE()     _LEAVE(__FILE__,__LINE__,__FUNC__)
  72.  #define RETURN(r)      _RETURN(__FILE__,__LINE__,__FUNC__,(unsigned long)r)
  73.  #define SHOWVALUE(v)      _SHOWVALUE((ULONG)v,sizeof(v),#v,__FILE__,__LINE__)
  74.  #define SHOWPOINTER(p)    _SHOWPOINTER(p,#p,__FILE__,__LINE__)
  75.  #define SHOWSTRING(s)     _SHOWSTRING(s,#s,__FILE__,__LINE__)
  76.  #define SHOWMSG(s)     _SHOWMSG(s,__FILE__,__LINE__)
  77.  #define D(s)        do { _DPRINTF_HEADER(__FILE__,__LINE__); _DPRINTF s; } while(0)
  78.  #define PRINTHEADER()     _DPRINTF_HEADER(__FILE__,__LINE__)
  79.  #define PRINTF(s)      _DLOG s
  80.  #define LOG(s)         do { _DPRINTF_HEADER(__FILE__,__LINE__); _DLOG("<%s()>:",__FUNC__); _DLOG s; } while(0)
  81.  #define SETDEBUGLEVEL(l)  _SETDEBUGLEVEL(l)
  82.  #define PUSHDEBUGLEVEL(l) _PUSHDEBUGLEVEL(l)
  83.  #define POPDEBUGLEVEL()   _POPDEBUGLEVEL()
  84.  #define SETPROGRAMNAME(n) _SETPROGRAMNAME(n)
  85.  #define GETDEBUGLEVEL()   _GETDEBUGLEVEL()
  86.  #define INDENT()    _INDENT()
  87.  
  88.  extern int __debug_level;
  89.  
  90.  #undef DEBUG
  91.  #define DEBUG 1
  92. #else
  93.  #define ASSERT(x)      ((void)0)
  94.  #define ENTER()     ((void)0)
  95.  #define LEAVE()     ((void)0)
  96.  #define RETURN(r)      ((void)0)
  97.  #define SHOWVALUE(v)      ((void)0)
  98.  #define SHOWPOINTER(p)    ((void)0)
  99.  #define SHOWSTRING(s)     ((void)0)
  100.  #define SHOWMSG(s)     ((void)0)
  101.  #define D(s)        ((void)0)
  102.  #define PRINTHEADER()     ((void)0)
  103.  #define PRINTF(s)      ((void)0)
  104.  #define LOG(s)         ((void)0)
  105.  #define SETDEBUGLEVEL(l)  ((void)0)
  106.  #define PUSHDEBUGLEVEL(l) ((void)0)
  107.  #define POPDEBUGLEVEL()   ((void)0)
  108.  #define SETPROGRAMNAME(n) ((void)0)
  109.  #define GETDEBUGLEVEL()   (0)
  110.  #define INDENT()    ((void)0)
  111.  
  112.  #ifdef DEBUG
  113.  #undef DEBUG
  114.  #endif /* DEBUG */
  115.  
  116.  #define DEBUG 0
  117. #endif /* DEBUG */
  118.  
  119. /****************************************************************************/
  120.  
  121. #endif /* _ASSERT_H */
  122.